<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="tag" uri="http://www.springframework.org/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%>


<security:authorize access="isAuthenticated()">
<security:authentication property="principal.username" var="username" scope="request"/>
<div id="userProfile">
	<div class="profile">
		<h2>Jesteś już zalogowany i nie możesz się ponownie zarejestrować!</h2>
	</div>
</div>
</security:authorize>

<security:authorize access="isAnonymous()">	


<div id="registration">
<div style="height: 100%; overflow: auto;">
	<div id="registrationFormWrapper">
		<form:form commandName="user" action="/register" id="registrationForm">
			<fieldset>
				<ul>
					<li><form:label path="username">
							*<spring:message code="label.login" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input path="username" />
							</div>
						</div>
						
						<form:errors path="username" element="div" class="form-error ui-state-error ui-corner-all"/>
						<div class="clear"></div>
						
						</li>

					<li><form:label path="password">
							*<spring:message code="label.password" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input type="password" path="password" />
							</div>
						</div>
						<form:errors path="password" element="div" class="form-error ui-state-error ui-corner-all"/>
						<div class="clear"></div></li>


					<li><form:label path="repeatedPassword">
							*<spring:message code="label.repeatpassword" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input type="password" path="repeatedPassword" />
							</div>
						</div>
						<form:errors path="repeatedPassword" element="div" class="form-error ui-state-error ui-corner-all"/>
						<div class="clear"></div></li>
						
						<li><form:label path="email">
							*<spring:message code="label.email" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input path="email" />
							</div>
						</div>
						<form:errors path="email" element="div" class="form-error ui-state-error ui-corner-all"/>			
						<div class="clear"></div></li>
						
						<li><form:label path="userAdditionalInformations.firstName">
							<spring:message code="label.firstname" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input path="userAdditionalInformations.firstName" />
							</div>
						</div>
						<div class="clear"></div></li>
						
						<li><form:label path="userAdditionalInformations.lastName">
							<spring:message code="label.lastname" />:
						</form:label>
						<div class="inputWrapper">
							<div class="cap">
								<form:input path="userAdditionalInformations.lastName" />
							</div>
						</div>
						<div class="clear"></div></li>

					<li>
						<button class="btn" type="submit">
							<div>
								<span><spring:message code="registration.button" /></span>
							</div>
						</button>
						<div class="clear"></div>
					</li>
				</ul>
				<div class="clear"></div>
			</fieldset>

		</form:form>
	</div>
</div>
</div>
<script type="text/javascript">
	$('#registrationForm').submit(function() {
		registerUserAjax(this);
		return false;
	});
</script>
</security:authorize>